Skip to main content

Requesting Clickstream

๐Ÿ“˜ Information below might be outdated - please visit our recently updated API Reference

The instruction below shows how to request clickstream.

This feature is available starting from Team plan.

1) Get your API key here: https://app.short.io/settings/integrations/api-keyโ€‹

  • Click "Create API key".
  • Add a Secret key.

Short.io API key creation page with Secret and Public key options

2) Copy an ID of a domain you want to request clickstream.โ€‹

  • Open domain settings.
  • Copy the domain ID.

Domain settings gear icon in the Short.io dashboard

Domain ID highlighted in domain settings panel

3) Install prerequisites for requests.โ€‹

pip install requests

Now everything is ready to run the following snippet. It will return a list of latest clicks.

4) Create a file: filename.py/ .js/ .rb. Use the code snippet below.โ€‹

๐Ÿ“˜

Please, replace domainID, exclude parameters with appropriate values.

๐Ÿ‘

You can include or exclude such options as countries, browsers, socials, browserVersions, statuses, paths, protos, methods, utmSources, utmMediums, utmCampaigns.

import requests

url = "https://api-v2.short.io/statistics/domain/domainID/last_clicks"

payload = {"limit":30, "include":{"human":True},"exclude":{"browsers":["Chrome"]}}
headers = {
'accept': "*/*",
'content-type': "application/json",
'authorization': "<<apiKey>>"
}

response = requests.request("POST", url, json=payload, headers=headers)

print(response.text)

5) Launch the file.โ€‹

python filename.py

6) JSON Response.โ€‹

Once you run the code, you will see the response.

It contains the list from the last 30 clicks. The example of one click.
{
host: 'shortcm.xyz',
path: '/login',
method: 'GET',
url: 'https://app.short.cm/login',
dt: '2020-05-20T06:19:12.000Z',
st: 302,
ip: '202.83.57.227',
proto: 'https',
ref: 'https://blog-short-io.cdn.ampproject.org/v/s/blog.short.io/shortlinks-youtube/amp/?amp_js_v=a3&amp_gsa=1&usqp=mq331AQFKAGwASA%3D',
ua: 'Mozilla/5.0 (Linux; Android 10; HD1901) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.138 Mobile Safari/537.36',
human: true,
browser: 'Chrome Mobile',
browser_version: '81',
country: 'India',
social: '',
refhost: 'blog-short-io.cdn.ampproject.org',
os: 'Android',
utm_source: '',
utm_medium: 'unknown',
utm_campaign: '',
goal_completed: null,
ab_path: null,
lcpath: '/login'
},